{{define "content"}}
<div class="container">
  <div class="row">
    <div class="col-md-12">
      <h2>Actions</h2>
      {{if .error}}
      <div class="alert alert-danger alert-dismissible" role="alert">
        <button type="button" class="close" data-dismiss="alert"><span>&times;</span></button>
        <strong>Error!</strong> {{index .error 0}}
      </div>
      {{end}} {{if .actions}}
      <table class="table table-striped table-bordered">
        <thead>
          <tr>
            <th>Action</th>
            <th>Status</th>
            <th>Started/Finished</th>
            <th>error</th>
            <th>&nbsp;</th>
          </tr>
        </thead>
        {{$base_path := .base_path}} {{range $index, $action := .actions}}
        <tr>
          <td>
            <span class="d-block">{{$action.Name}}</span>
            <!--TODO: after bootstrap upgrade remove this-->
            <br />
            <span class="text-muted">{{$action.Description}}</span>
          </td>
          <td>{{if $action.IsRunning}}running{{else}}not running{{end}} </td>
          <td>Started: {{$action.StartTime}}<br /> Finished: {{$action.FinishedTime}}</td>
          <td>
            {{if $action.Error}} {{$action.Error.Error}} {{end}}
          </td>
          <td>
            {{if not $action.IsRunning}}
            <form class="form-inline" method="POST" action="{{$base_path}}/start/{{$action.Name}}">
              <div class="form-group">
                <label for="value_{{$action.Name}}">Value</label>
                <input id="value_{{$action.Name}}" class="form-control" type="text" name="value" placeholder="optional value to pass to action" />
              </div>
              <button type="submit" class="btn btn-sm btn-primary">Start</button>
            </form>
            {{else}}
            <form class="form-inline" method="POST" action="{{$base_path}}/stop/{{$action.Name}}">
              <button type="submit" class="btn btn-sm btn-secondary">Stop</button>
            </form>
            {{end}}
          </td>

        </tr>

        {{end}}
        </ul>
        {{else}}
        <div class="alert alert-info">No actions defined.</div>
        {{end}}
    </div>
  </div>
</div>
{{end}}